//
//  VisitorView.swift
//  LXQWB
//
//  Created by 江海天 on 2017/7/3.
//  Copyright © 2017年 江海天. All rights reserved.
//

import UIKit

class VisitorView: UIView {

	@IBOutlet weak var rotation: UIImageView!
	
	@IBOutlet weak var titleImage: UIImageView!

	@IBOutlet weak var title: UILabel!

	@IBOutlet weak var loginBtn: UIButton!

	@IBOutlet weak var registerBtn: UIButton!
	
	func setView(imageName:String?,imageBackgroudName:String?,title:String?){
		
		guard let image = imageName else {
			setAnimation()
			return
		}
		
		rotation.isHidden = true
		titleImage.image = UIImage(named: image)
		self.title.text = title
		

		

	}
	
	private func setAnimation(){
		let animation = CABasicAnimation()
		animation.duration = 5
		animation.repeatCount = MAXFLOAT
		animation.keyPath = "transform.rotation"
		animation.toValue = 2 * Double.pi
		animation.isRemovedOnCompletion = false
		rotation.layer.add(animation, forKey: nil)
	}
	
	class func visitorView()->VisitorView?{
		return Bundle.main.loadNibNamed("VisitorView", owner: nil, options: nil)?.last as? VisitorView
	}

}
